package com.fancy.mobileschool.ui.fragment;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.fancy.mobileschool.R;
import com.fancy.mobileschool.entity.YunFile;
import com.fancy.mobileschool.ui.adapt.TransferFileListAdapter;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Jackie on 2017/11/16.
 */

public class TransferFileListFragment extends Fragment {

    private RecyclerView recyclerView;

    private TransferFileListAdapter adapter;

    @Override
    public void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    }

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        recyclerView = (RecyclerView) inflater.inflate(R.layout.fragment_file_list, container, false);
//        List<YunFile> list = new ArrayList<>();
//        list.add(new YunFile(1, "test.txt", "2", "343", "personFile"));
//        list.add(new YunFile(1, "test1.txt", "2", "343", "personFile"));
//        list.add(new YunFile(1, "test2.txt", "2", "343", "personFile"));
//        list.add(new YunFile(1, "test3.txt", "2", "343", "personFile"));
//        list.add(new YunFile(1, "test4.txt", "2", "343", "personFile"));
//
//        List<YunFile> list1 = new ArrayList<>();
//        list1.add(new YunFile(1, "test.txt", "2", "343", "courseFile"));
//        list.add(new YunFile(1, "test1.txt", "2", "343", "courseFile"));
//        list1.add(new YunFile(1, "test2.txt", "2", "343", "courseFile"));
//        list1.add(new YunFile(1, "test3.txt", "2", "343", "courseFile"));

        adapter = new TransferFileListAdapter(new ArrayList<YunFile>(), new ArrayList<YunFile>(), new ArrayList<YunFile>(), getActivity());
        recyclerView.setAdapter(adapter);

        return recyclerView;
    }

    public void addFile2Upload(YunFile yunFile) {
        adapter.addFile2UploadingFiles(yunFile);
        adapter.notifyDataSetChanged();
    }

    public void moveUploadFile2End(YunFile yunFile) {
        adapter.removeFromUploadingFiles(yunFile).addFile2AlreadyUploadFiles(yunFile);
        adapter.notifyDataSetChanged();
    }

}
